home *** CD-ROM | disk | FTP | other *** search
/ 17 Bit Software 6: Level 6 / 17 Bit - Level 6 (1998)(Epic Marketing)[!].iso / quartz / q0429.dms / q0429.adf / etc / rsconvert / yacc.y < prev   
Text File  |  1992-05-20  |  14KB  |  757 lines

  1. /* yacc.y                                   */
  2. /*                                       */
  3. /* Copyright (C) 1989, 1991, Craig E. Kolb                   */
  4. /* All rights reserved.                               */
  5. /*                                       */
  6. /* This software may be freely copied, modified, and redistributed,       */
  7. /* provided that this copyright notice is preserved on all copies.       */
  8. /*                                       */
  9. /* You may not distribute this software, in whole or in part, as part of   */
  10. /* any commercial product without the express consent of the authors.      */
  11. /*                                        */
  12. /* There is no warranty or other guarantee of fitness of this software       */
  13. /* for any purpose.  It is provided solely "as is".               */
  14. /* $Id: yacc.y,v 4.0.1.3 92/02/07 11:05:21 cek Exp Locker: cek $ */
  15. %{
  16. #include <stdio.h>
  17. #include "libcommon/common.h"
  18.  
  19. #define NEWLINE()    WriteNewline()
  20. /*#define NEWLINE()    printf("\n")*/
  21. #define LIST    0
  22. #define GRID    1
  23. char yyfilename[BUFSIZ];
  24. extern int yylineno;
  25. %}
  26. %union {
  27.     char *c;
  28.     int i;
  29.     double d;
  30.     Color col;
  31.     Vector v;
  32. };
  33. %token <d> tFLOAT
  34. %token <c> tSTRING tHASHTHING
  35. %token <i> tINT
  36. %type <d> Fnumber sFnumber
  37. %type <col> sColor
  38. %type <v> sVector
  39. %type <i> sInt
  40. %type <c> sString
  41. %token tADAPTIVE tAPERTURE
  42. %token tBACKGROUND tBLOTCH tBOX tBUMP tCONE tCYL tDIRECTIONAL
  43. %token tENDDEF tEXTENDED tEYEP tFBM tFBMBUMP tFOCALDIST tFOG tFOV tGLOSS tGRID
  44. %token tHEIGHTFIELD tJITTERED tLIGHT tLIST tLOOKP tMARBLE tMAXDEPTH tMIST
  45. %token tOBJECT tOUTFILE
  46. %token tPLANE tPOINT tPOLY tROTATE tSAMPLES
  47. %token tSCALE tSCREEN tSPHERE tSTARTDEF tSUPERQ tSURFACE tRESOLUTION
  48. %token tTHRESH tTRANSLATE tTRANSFORM tTRIANGLE tUP tENDFILE
  49. %token tTEXTURE tCHECKER tWOOD tCONTRAST tCUTOFF
  50. %%
  51. Items        : /* empty */
  52.         | Items Item
  53.         ;
  54. Item        : Eyep
  55.         | Lookp
  56.         | Up
  57.         | Fov
  58.         | Screen
  59.         | Aperture
  60.         | Focaldist
  61.         | Maxdepth
  62.         | Samples
  63.         | Jittered
  64.         | Adaptive
  65.         | Contrast
  66.         | Cutoff
  67.         | Background
  68.         | Light
  69.         | Primitive
  70.         | Child
  71.         | Surface
  72.         | Outfile
  73.         | List
  74.         | Grid
  75.         | Object
  76.         | Fog
  77.         | Mist
  78.         | Hashthing
  79.         | ENDFILE        /* For backward compatibility */
  80.         ;
  81. Hashthing    : tHASHTHING
  82.         {
  83.             WriteVerbatim("\n#");
  84.             WriteVerbatim($1);
  85.             WriteNewline();
  86.         };
  87. List        : LIST
  88.         {
  89.             NEWLINE();
  90.         }
  91.         ;
  92. Grid        : GRID
  93.         {
  94.             NEWLINE();
  95.         }
  96.         ;
  97. Primitive    : Prim Textures
  98.         ;
  99. Prim        : Primtype Transforms
  100.         ;
  101. Primtype    : Plane
  102.         | Sphere
  103.         | Box
  104.         | Triangle
  105.         | Cylinder
  106.         | Cone
  107.         | Superq
  108.         | Poly
  109.         | HeightField
  110.         ;
  111. Object        : Objectdef Textures
  112.         {
  113.             NEWLINE();
  114.         }
  115.         ;
  116. Objectdef    : Startdef Objdefs ENDDEF
  117.         ;
  118. Startdef    : STARTDEF
  119.         /*
  120.          * define <name>
  121.          */
  122.         {
  123.             NEWLINE();
  124.         }
  125.         ;
  126. Objdefs        : Objdefs Objdef
  127.         |
  128.         ;
  129. Objdef        : Primitive
  130.         | Surface
  131.         | Child
  132.         | List
  133.         | Grid
  134.         | Object
  135.         ;
  136. Textures    : Textures Texture
  137.         |
  138.         ;
  139. Texture        : TEXTURE Texturetype Transforms
  140.         {
  141.             NEWLINE();
  142.         }
  143.         ;
  144. Texturetype    : CHECKER String
  145.         {
  146.             NEWLINE();
  147.         }
  148.         | BLOTCH Fnumber String
  149.         {
  150.             NEWLINE();
  151.         }
  152.         | BUMP Fnumber
  153.         {
  154.             NEWLINE();
  155.         }
  156.         | MARBLE
  157.         {
  158.             NEWLINE();
  159.         }
  160.         | MARBLE String
  161.         {
  162.             NEWLINE();
  163.         }
  164.         | FBM Fnumber Fnumber Fnumber Fnumber Int Fnumber
  165.         {
  166.             NEWLINE();
  167.         }
  168.         | FBM Fnumber Fnumber Fnumber Fnumber Int Fnumber String
  169.         {
  170.             NEWLINE();
  171.         }
  172.         | FBMBUMP Fnumber Fnumber Fnumber Fnumber Int
  173.         {
  174.             NEWLINE();
  175.         }
  176.         | WOOD
  177.         {
  178.             NEWLINE();
  179.         }
  180.         | GLOSS Fnumber
  181.         {
  182.             NEWLINE();
  183.         }
  184.         ;
  185. Child        : Childdef Textures
  186.         {
  187.             NEWLINE();
  188.         }
  189.         ;
  190. Childdef    : OBJECT String Transforms
  191.         {
  192.             NEWLINE();
  193.         }
  194.         ;
  195. Transforms    : Transforms Transform
  196.         | /* empty */
  197.         ;
  198. Transform    : TRANSLATE Vector
  199.         {
  200.             NEWLINE();
  201.         }
  202.         | ROTATE Vector sFnumber
  203.         {
  204.             WriteFloat(-$3);
  205.             NEWLINE();
  206.         }
  207.         | SCALE Fnumber Fnumber Fnumber
  208.         {
  209.             NEWLINE();
  210.         }
  211.         | TRANSFORM sFnumber sFnumber sFnumber
  212.                 sFnumber sFnumber sFnumber
  213.                 sFnumber sFnumber sFnumber
  214.         {
  215.             /* have to transpose... */
  216.             WriteFloat($2); WriteFloat($5); WriteFloat($8);
  217.             WriteFloat($3); WriteFloat($6); WriteFloat($9);
  218.             WriteFloat($4); WriteFloat($7); WriteFloat($10);
  219.             NEWLINE();
  220.         }
  221.         | TRANSFORM sFnumber sFnumber sFnumber
  222.                 sFnumber sFnumber sFnumber
  223.                 sFnumber sFnumber sFnumber
  224.                 sFnumber sFnumber sFnumber
  225.         {
  226.             /* transpose it */
  227.             WriteFloat($2); WriteFloat($5); WriteFloat($8);
  228.             WriteFloat($3); WriteFloat($6); WriteFloat($9);
  229.             WriteFloat($4); WriteFloat($7); WriteFloat($10);
  230.             WriteFloat($11); WriteFloat($12); WriteFloat($13);
  231.             NEWLINE();
  232.         }
  233.         ;
  234. Eyep        : EYEP Vector Transforms
  235.         {
  236.             NEWLINE();
  237.         }
  238.         ;
  239. Lookp        : LOOKP Vector
  240.         {
  241.             NEWLINE();
  242.         }
  243.         ;
  244. Up        : UP Vector
  245.         {
  246.             NEWLINE();
  247.         }
  248.         ;
  249. Fov        : FOV Fnumber Fnumber
  250.         {
  251.             NEWLINE();
  252.         }
  253.         | FOV Fnumber
  254.         {
  255.             NEWLINE();
  256.         }
  257.         ;
  258. Samples        : SAMPLES Int
  259.         {
  260.             NEWLINE();
  261.         }
  262.         ;
  263. Adaptive    : ADAPTIVE sInt
  264.         {
  265.             WriteFloat((Float)($2+1));
  266.             NEWLINE();
  267.         }
  268.         ;
  269. Contrast    : CONTRAST Fnumber Fnumber Fnumber
  270.         {
  271.             NEWLINE();
  272.         }
  273.         ;
  274. Cutoff        : CUTOFF Fnumber
  275.         {
  276.             NEWLINE();
  277.         }
  278.         ;
  279. Jittered    : JITTERED
  280.         {
  281.             NEWLINE();
  282.         }
  283.         ;
  284. Screen        : SCREEN Int Int
  285.         {
  286.             NEWLINE();
  287.         }
  288.         | RESOLUTION Int Int
  289.         {
  290.             NEWLINE();
  291.         }
  292.         ;
  293. Aperture    : APERTURE Fnumber
  294.         {
  295.             NEWLINE();
  296.         }
  297.         ;
  298. Focaldist    : FOCALDIST Fnumber
  299.         {
  300.             NEWLINE();
  301.         }
  302.         ;
  303. Maxdepth    : MAXDEPTH Int
  304.         {
  305.             NEWLINE();
  306.         }
  307.         ;
  308. Background    : BACKGROUND Color
  309.         {
  310.             NEWLINE();
  311.         }
  312.         ;
  313. Light        : Lightdef POINT Vector
  314.         {
  315.             NEWLINE();
  316.         }
  317.         | Lightdef DIRECTIONAL Vector
  318.         {
  319.             NEWLINE();
  320.         }
  321.         | Lightdef EXTENDED sVector sFnumber
  322.         {
  323.             WriteFloat($4);
  324.             WriteVector(&$3);
  325.             NEWLINE();
  326.         }
  327.         ;
  328. Lightdef    : LIGHT Fnumber
  329.         {
  330.             NEWLINE();
  331.         }
  332.         | LIGHT Color
  333.         {
  334.             NEWLINE();
  335.         }
  336.         ;
  337. Surface        : SURFACE String
  338.             sColor sColor sColor
  339.             sFnumber sFnumber sFnumber sFnumber
  340.         {
  341.             if ($3.r || $3.g || $3.b) {
  342.                 WriteString("\tambient");
  343.                 WriteColor(&$3);
  344.                 WriteNewline();
  345.             }
  346.             if ($4.r || $4.g || $4.b) {
  347.                 WriteString("\tdiffuse");
  348.                 WriteColor(&$4);
  349.                 WriteNewline();
  350.             }
  351.             if ($5.r || $5.g || $5.b) {
  352.                 WriteString("\tspecular");
  353.                 WriteColor(&$5);
  354.                 WriteNewline();
  355.                 if ($6) {
  356.                     WriteString("\tspecpow");
  357.                     WriteFloat($6);
  358.                     WriteNewline();
  359.                 }
  360.             }
  361.             if ($7) {
  362.                 WriteString("\treflect");
  363.                 WriteFloat($7);
  364.                 WriteNewline();
  365.             }
  366.             if ($8) {
  367.                 WriteString("\ttransp");
  368.                 WriteFloat($8);
  369.                 WriteString("index");
  370.                 WriteFloat($9);
  371.                 WriteNewline();
  372.             }
  373.         }
  374.         | SURFACE String sColor sColor sColor
  375.             sFnumber sFnumber sFnumber sFnumber sFnumber sFnumber
  376.         {
  377.             if ($3.r || $3.g || $3.b) {
  378.                 WriteString("\tambient");
  379.                 WriteColor(&$3);
  380.                 WriteNewline();
  381.             }
  382.             if ($4.r || $4.g || $4.b) {
  383.                 WriteString("\tdiffuse");
  384.                 WriteColor(&$4);
  385.                 WriteNewline();
  386.             }
  387.             if ($5.r || $5.g || $5.b) {
  388.                 WriteString("\tspecular");
  389.                 WriteColor(&$5);
  390.                 WriteNewline();
  391.                 if ($6) {
  392.                     WriteString("\tspecpow");
  393.                     WriteFloat($6);
  394.                     WriteNewline();
  395.                 }
  396.             }
  397.             if ($7) {
  398.                 WriteString("\treflect");
  399.                 WriteFloat($7);
  400.                 WriteNewline();
  401.             }
  402.             if ($8) {
  403.                 WriteString("\ttransp");
  404.                 WriteFloat($8);
  405.                 WriteString("index");
  406.                 WriteFloat($9);
  407.                 WriteNewline();
  408.             }
  409.             if ($10) {
  410.                 WriteString("\ttranslu");
  411.                 WriteFloat($10);
  412.                 WriteString("1 1 1");
  413.                 WriteFloat($11);
  414.                 WriteNewline();
  415.             }
  416.         }
  417.         ;
  418. HeightField    : HEIGHTFIELD String String
  419.         {
  420.             NEWLINE();
  421.         }
  422.         ;
  423. Poly        : POLY String Polypoints
  424.         {
  425.             NEWLINE();
  426.         }
  427.         ;
  428. Polypoints    : /* empty */
  429.         | Polypoints Polypoint
  430.         ;
  431. Polypoint    : Vector
  432.         {
  433.             NEWLINE();
  434.         }
  435.         ;
  436. Cone        : CONE String sVector sVector sFnumber sFnumber
  437.         {
  438.             /* Radii now precede points */
  439.             WriteFloat($5);
  440.             WriteVector(&$3);
  441.             WriteFloat($6);
  442.             WriteVector(&$4);
  443.             NEWLINE();
  444.         }
  445.         ;
  446. Cylinder    : CYL sString sVector sVector sFnumber
  447.         {
  448.             Vector tmp;
  449.  
  450.             WriteString($2);
  451.             /* Radius now goes first */
  452.             WriteFloat($5);
  453.             WriteVector(&$3);
  454.             WriteVector(&$4);
  455.             NEWLINE();
  456.             WriteVerbatim("#ifdef ENDCAPS\n");
  457.                 VecSub($3, $4, &tmp);
  458.                 WriteVerbatim("disc ");
  459.                 WriteString($2);
  460.                 WriteFloat($5);    /* radius */
  461.                 WriteVector(&$3); /* pos */
  462.                 WriteVector(&tmp);
  463.                 WriteVerbatim("\ndisc ");
  464.                 WriteString($2);
  465.                 VecScale(-1, tmp, &tmp);
  466.                 WriteFloat($5);    /* radius */
  467.                 WriteVector(&$4); /* pos */
  468.                 WriteVector(&tmp);
  469.             WriteVerbatim("\n#endif\n");
  470.         }
  471.         ;
  472. Sphere        : SPHERE String Fnumber Vector
  473.         {
  474.             NEWLINE();
  475.         }
  476.         ;
  477. Box        : BOX String
  478.             sFnumber sFnumber sFnumber
  479.             sFnumber sFnumber sFnumber
  480.         {
  481.             /* give box corners */
  482.             WriteFloat($3 - $6);
  483.             WriteFloat($4 - $7);
  484.             WriteFloat($5 - $8);
  485.             WriteFloat($3 + $6);
  486.             WriteFloat($4 + $7);
  487.             WriteFloat($5 + $8);
  488.             NEWLINE();
  489.         }
  490.         ;
  491. Triangle    : TRIANGLE String Vector Vector Vector
  492.         {
  493.             NEWLINE();
  494.         }
  495.         | TRIANGLE String Vector Vector Vector Vector Vector Vector
  496.         {
  497.             NEWLINE();
  498.         }
  499.         ;
  500. Superq        : SUPERQ String
  501.             Fnumber Fnumber Fnumber
  502.             Fnumber Fnumber Fnumber
  503.             Fnumber
  504.         {
  505.             WriteVerbatim("*/");
  506.             NEWLINE();
  507.         }
  508.         ;
  509. Plane        : PLANE String sVector sVector
  510.         {
  511.             /* reverse order of point/normal */
  512.             WriteVector(&$4);
  513.             WriteVector(&$3);
  514.             NEWLINE();
  515.         }
  516.         ;
  517. Outfile        : OUTFILE String
  518.         {
  519.             NEWLINE();
  520.         }
  521.         ;
  522. Mist        : MIST Color Color Fnumber Fnumber
  523.         {
  524.             NEWLINE();
  525.         }
  526.         ;
  527. Fog        : FOG sFnumber sColor
  528.         {
  529.             WriteColor(&$3);
  530.             WriteFloat($2); WriteFloat($2); WriteFloat($2);
  531.             NEWLINE();
  532.         }
  533.         ;
  534. Color        : Fnumber Fnumber Fnumber
  535.         ;
  536. sColor        : sFnumber sFnumber sFnumber
  537.         {
  538.             $$.r = $1; $$.g = $2; $$.b = $3;
  539.         }
  540.         ;
  541. Vector        : Fnumber Fnumber Fnumber
  542.         ;
  543. sVector        : sFnumber sFnumber sFnumber
  544.         {
  545.             $$.x = $1; $$.y = $2; $$.z = $3;
  546.         }
  547.         ;
  548. Fnumber        : tFLOAT
  549.         { WriteFloat($1); }
  550.         | tINT
  551.         { WriteFloat((Float)$1); }
  552.         ;
  553. Int        : tINT
  554.         { WriteFloat((Float)$1); };
  555. sInt        : tINT
  556.         { $$ = (int)$1; };
  557. sFnumber    : tFLOAT
  558.         | tINT
  559.         { $$ = (double)$1; }
  560.         ;
  561. String        : tSTRING
  562.         { WriteString($1); }
  563. sString        : tSTRING
  564.         { $$ = $1; }
  565. ADAPTIVE    : tADAPTIVE    { WriteString("samples"); }
  566. APERTURE    : tAPERTURE    { WriteString("aperture"); }
  567. BACKGROUND    : tBACKGROUND    { WriteString("background"); }
  568. BLOTCH        : tBLOTCH    { WriteString("blotch"); }
  569. BOX        : tBOX        { WriteString("box"); }
  570. BUMP        : tBUMP        { WriteString("bump"); }
  571. CONE        : tCONE        { WriteString("cone"); }
  572. CYL        : tCYL        { WriteString("cylinder"); }
  573. DIRECTIONAL    : tDIRECTIONAL    { WriteString("directional"); }
  574. ENDDEF        : tENDDEF    { EndDefine(); }
  575. EXTENDED    : tEXTENDED    { WriteString("extended"); }
  576. EYEP        : tEYEP        { WriteString("eyep"); }
  577. FBM        : tFBM        { WriteString("fbm"); }
  578. FBMBUMP        : tFBMBUMP    { WriteString("fbmbump"); }
  579. FOCALDIST    : tFOCALDIST    { WriteString("focaldist"); }
  580. FOG        : tFOG        { WriteString("atmosphere fog"); }
  581. FOV        : tFOV        { WriteString("fov"); }
  582. GLOSS        : tGLOSS    { WriteString("gloss"); }
  583. GRID        : tGRID    tINT tINT tINT    { SetTypeGrid($2,$3,$4); }
  584. HEIGHTFIELD    : tHEIGHTFIELD    { WriteString("heightfield"); }
  585. JITTERED    : tJITTERED    { WriteString("jittered"); }
  586. LIGHT        : tLIGHT    { WriteString("light"); }
  587. LIST        : tLIST        { SetTypeList(); }
  588. LOOKP        : tLOOKP    { WriteString("lookp"); }
  589. MARBLE        : tMARBLE    { WriteString("marble"); }
  590. MAXDEPTH    : tMAXDEPTH    { WriteString("maxdepth"); }
  591. MIST        : tMIST        { WriteString("atmosphere mist"); }
  592. OBJECT        : tOBJECT    { WriteString("object"); }
  593. OUTFILE        : tOUTFILE    { WriteString("outfile"); }
  594. PLANE        : tPLANE    { WriteString("plane"); }
  595. POINT        : tPOINT    { WriteString("point"); }
  596. POLY        : tPOLY        { WriteString("poly"); }
  597. ROTATE        : tROTATE    { WriteString("rotate"); }
  598. SAMPLES        : tSAMPLES    { WriteString("samples"); }
  599. SCALE        : tSCALE    { WriteString("scale"); }
  600. SCREEN        : tSCREEN    { WriteString("screen"); }
  601. SPHERE        : tSPHERE    { WriteString("sphere"); }
  602. STARTDEF    : tSTARTDEF tSTRING    { StartDefine($2); }
  603. SUPERQ        : tSUPERQ    { WriteString("/* superq"); }
  604. SURFACE        : tSURFACE    { WriteString("surface"); }
  605. RESOLUTION    : tRESOLUTION    { WriteString("resolution"); }
  606. TRANSLATE    : tTRANSLATE    { WriteString("translate"); }
  607. TRANSFORM    : tTRANSFORM    { WriteString("transform"); }
  608. TRIANGLE    : tTRIANGLE    { WriteString("triangle"); }
  609. UP        : tUP        { WriteString("up"); }
  610. ENDFILE        : tENDFILE    { /* Don't do a thing. */ }
  611. TEXTURE        : tTEXTURE    { WriteString("texture"); }
  612. CHECKER        : tCHECKER    { WriteString("checker"); }
  613. WOOD        : tWOOD        { WriteString("wood"); }
  614. CONTRAST    : tCONTRAST    { WriteString("contrast"); }
  615. CUTOFF        : tCUTOFF    { WriteString("cutoff"); }
  616. %%
  617.  
  618. #define STARTBUFSIZ    (1 << 18)
  619.  
  620. typedef struct db {
  621.     int bufsiz, curpos;
  622.     int type, x, y, z;
  623.     char *name;
  624.     struct db *next;
  625.     char *memory;
  626. } DefBuf;
  627.  
  628. DefBuf *defbuf = NULL;
  629.  
  630. yyerror(s)
  631. {
  632.     fprintf(stderr,"rsconvert: %s, line %d: %s \n",
  633.             yyfilename[0] ? yyfilename : "stdin",
  634.             yylineno, s);
  635. }
  636.  
  637. StartDefine(name)
  638. char *name;
  639. {
  640.     DefBuf *new;
  641.     /*
  642.      * Push new buffer onto define stack.
  643.      */    
  644.     new = (DefBuf *)Malloc(sizeof(DefBuf));
  645.     new->bufsiz = STARTBUFSIZ;
  646.     new->type = LIST;
  647.     new->curpos = 0;
  648.     new->name = name;
  649.     new->memory = (char *)Calloc(new->bufsiz, sizeof(char));
  650.     new->next = defbuf;
  651.     defbuf = new;
  652. }
  653.  
  654. EndDefine()
  655. {
  656.     char buf[BUFSIZ];
  657.     DefBuf *old;
  658.  
  659.     old = defbuf;
  660.     defbuf = defbuf->next;
  661.     if (old->type == LIST) {
  662.         sprintf(buf, "name %s list", old->name);
  663.     } else {
  664.         sprintf(buf, "name %s grid %d %d %d", old->name,
  665.                 old->x, old->y, old->z);
  666.     }
  667.     /*
  668.      * dump goodies
  669.      */
  670.     WriteVerbatim(buf);
  671.     WriteVerbatim(old->memory);
  672.     WriteVerbatim("end");
  673.     free((voidstar)old->memory);
  674.     free((voidstar)old);
  675.     
  676. }
  677.  
  678. WriteString(str)
  679. char *str;
  680. {
  681.     WriteVerbatim(str);
  682.     WriteChar(' ');
  683. }
  684.  
  685. WriteVerbatim(str)
  686. char *str;
  687. {
  688.     int n;
  689.  
  690.     for (n = strlen(str); n; n--)
  691.         WriteChar(*(str++));
  692. }
  693.  
  694. WriteChar(c)
  695. char c;
  696. {
  697.     if (defbuf) {
  698.         if (defbuf->curpos == defbuf->bufsiz -1) {
  699.             defbuf->bufsiz *= 2;
  700.             defbuf->memory = (char *)realloc(defbuf->memory,
  701.                 defbuf->bufsiz * sizeof(char));
  702.             if (defbuf->memory == (char *)NULL) {
  703.                 fprintf(stderr,"realloc failed!\n");
  704.                 exit(-1);
  705.             }
  706.         }
  707.         defbuf->memory[defbuf->curpos++] = c;
  708.         defbuf->memory[defbuf->curpos] = (char)NULL;
  709.     } else
  710.         putchar(c);
  711. }
  712.  
  713. WriteVector(v)
  714. Vector *v;
  715. {
  716.     WriteFloat(v->x);
  717.     WriteFloat(v->y);
  718.     WriteFloat(v->z);
  719. }
  720.  
  721. WriteFloat(x)
  722. Float x;
  723. {
  724.     char buf[BUFSIZ];
  725.     sprintf(buf, "%g ", x);
  726.     WriteVerbatim(buf);
  727. }
  728.  
  729. WriteNewline()
  730. {
  731.     WriteVerbatim("\n");
  732. }
  733.  
  734. SetTypeList()
  735. {
  736.     if (defbuf)
  737.         defbuf->type = LIST;
  738.     /* else set world type */
  739. }
  740.  
  741. SetTypeGrid(x,y,z)
  742. int x, y, z;
  743. {
  744.     if (defbuf) {
  745.         defbuf->type = GRID;
  746.         defbuf->x = x; defbuf->y = y; defbuf->z = z;
  747.     } /* else set world type */
  748. }
  749.  
  750. WriteColor(c)
  751. Color *c;
  752. {
  753.     WriteFloat(c->r);
  754.     WriteFloat(c->g);
  755.     WriteFloat(c->b);
  756. }
  757.